package com.lian.pet.controller;

import com.lian.pet.common.basic.response.AppResp;
import com.lian.pet.domain.dto.AddPetFeedinglogsDTO;
import com.lian.pet.domain.dto.QueryPetFeedinglogsDTO;
import com.lian.pet.domain.vo.PetFeedinglogsVO;
import com.lian.pet.service.PetFeedinglogsService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RequestMapping("petfeedinglogs")
@RestController
@AllArgsConstructor
public class PetFeedinglogsController {
    private final PetFeedinglogsService petFeedinglogsService;

    /**
     * 新增饲养记录
     * @param req
     */
    @PostMapping("/add")
    public AppResp<Void> addpetFeedinglogs(@RequestBody AddPetFeedinglogsDTO req) {
        petFeedinglogsService.addPetFeedinglogs(req);
        return AppResp.succeed(null);
    }

    /**
     * 查询饲养记录列表
     * @param req
     * @return
     */
    @PostMapping("/queryList")
    public AppResp<List<PetFeedinglogsVO>> queryPetFeedinglogs(@RequestBody QueryPetFeedinglogsDTO req) {
        return AppResp.succeed(petFeedinglogsService.queryPetFeedinglogs(req));
    }

    /**
     * 查询饲养记录信息
     * @param id
     * @return
     */
    @GetMapping("/getById")
    public AppResp<PetFeedinglogsVO> getpetFeedinglogsById(@RequestParam("id") Integer id) {
        return AppResp.succeed(petFeedinglogsService.getPetFeedinglogs(id));
    }

    /**
     * 删除饲养记录信息
     * @param id
     */
    @GetMapping("/deleteById")
    public AppResp<Integer> deleteById(@RequestParam("id") Integer id) {
        petFeedinglogsService.deletePetFeedinglogs(id);
        return AppResp.succeed(1);
    }

    /**
     * 修改饲养记录信息
     * @param req
     * @param id
     * @return
     */
    @PostMapping("/updateById")
    public AppResp<Void> updateById(@RequestParam("id") Integer id, @RequestBody AddPetFeedinglogsDTO req) {
        petFeedinglogsService.updatePetFeedinglogs(id, req);
        return AppResp.succeed(null);
    }

}
